﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ListItemEditor.UI
{
    public partial class MultiSelectForm : Form
    {
        public MultiSelectForm()
        {
            InitializeComponent();
        }

        public static DialogResult ShowMultiSelect(IWin32Window owner, string caption, object choices, string displayMember, string valueMember, ref List<object> selectedIDs, Point location, Size size, FormStartPosition startPosition)
        {
            MultiSelectForm form = new MultiSelectForm();
            if (!string.IsNullOrEmpty(caption)) form.Text = caption;
            form.StartPosition = startPosition;
            form.Location = location;
            form.Size = size;
            form.MultiSelect.ChoicesSorted = true;
            form.MultiSelect.Choices = choices;
            form.MultiSelect.SelectedValues = selectedIDs;
            form.MultiSelect.DisplayMember = displayMember;
            form.MultiSelect.ValueMember = valueMember;
            form.MultiSelect.DataBind();

            DialogResult result = form.ShowDialog(owner);
            if (result == DialogResult.OK) { selectedIDs = form.MultiSelect.SelectedValues; }
            return result;
        }

        private void MultiSelectForm_Load(object sender, EventArgs e)
        {
        }
    }
}